<template>
	<view class="content">
		<view class="cu-modal bottom-modal" :class="[{ show: showModal }]" cathctouchmove @click="hideModal">
			<view class="cu-dialog" style="background: none; overflow: visible;">
				<view class="share-box">
					<view class="share-list-box">
						<!-- #ifdef MP-WEIXIN -->
						<button open-type="share" class="share-item">
							<image class="share-img" src="/static/images/share/share_wx.png"></image>
							<text class="share-title">分享给朋友</text>
						</button>
						<!-- #endif -->
						<view class="share-item" @click="createImage">
							<image class="share-img" src="/static/images/share/share_poster.png" mode=""></image>
							<text class="share-title">分享海报</text>
						</view>

						<view class="share-item" v-if="link" @click="copyLink">
							<image class="share-img" src="/static/images/share/share_link.png" mode=""></image>
							<text class="share-title">复制链接</text>
						</view>
					</view>
					<view class="share-foot" @click="hideModal">取消</view>
				</view>
			</view>
		</view>
		<!-- 指引 -->
		<np-share-guide v-model="showShareGuide"></np-share-guide>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				showShareGuide: false,
				shareData: {},
				domain: "",
				path: "",
				shareTitle: "",
				userShareLink: "",
				showGoodsCanvas: false
			};
		},
		props: {
			value: {},
			api: {
				type: String,
				default: ''
			},
			link: {
				type: String,
				default: ''
			},
			goodsInfo: {}, //商品信息
		},
		computed: {
			...mapState(['hasLogin', 'userInfo']),
			showModal: {
				get() {
					return this.value;
				},
				set(val) {
					this.$emit('input', val);
				}
			}
		},
		methods: {
			createImage(){
				this.$emit('canvas');
			},
			copyLink() {
				this.showModal = false;
				uni.setClipboardData({
					data: this.link,
					success: (res) => {
						//#ifdef H5
						this.$config.toast('已复制到剪切板');
						//#endif
					},
					fail: (err) => {
						//#ifdef H5
						this.$config.toast('未知错误,复制失败');
						//#endif
					}
				});
			},
			hideModal() {
				this.showModal = false;
			},
		}
	};
</script>

<style lang="scss">
	.share-box {
		background: #fff;
		width: 750rpx;
		border-radius: 30rpx 30rpx 0 0;
		padding-top: 30rpx;
		position: relative;

		.share-foot {
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 24rpx;
			color: #bfbfbf;
			height: 80rpx;
			border-top: 1rpx solid #eee;
		}

		.share-list-box {
			display: flex;
			justify-content: space-around;

			.share-btn {
				background: none;
				border: none;
				line-height: 1;
				padding: 0;

				&::after {
					border: none;
				}
			}

			.share-item {
				flex: 1;
				padding-bottom: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				.share-img {
					width: 70rpx;
					height: 70rpx;
					background: rgba(246, 246, 254, 1);
					border-radius: 50%;
					margin-bottom: 20rpx;
				}

				.share-title {
					font-size: 24rpx;
					color: #666;
				}
			}
		}
	}

	.haibao {
		padding: 10rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
	}

	.bottom {
		margin: 20rpx 0;
		display: flex;
		align-items: center;
	}
</style>
